#include<cstdio>
#include<algorithm>
#define inf 0X7FFFFFFF
using namespace std;
int n,cost=inf;
int x1,y1,x2,y2;
struct data
{
    int x,y,dist1,dist2;
}a[100005];
bool cmp(data a,data b)
{
    return a.dist1<b.dist1;
}
int main()
{
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a[i].x,&a[i].y);
        a[i].dist1=(a[i].x-x1)*(a[i].x-x1)+(a[i].y-y1)*(a[i].y-y1);
        a[i].dist2=(a[i].x-x2)*(a[i].x-x2)+(a[i].y-y2)*(a[i].y-y2);
    }
    sort(a+1,a+n+1,cmp);
    int r=0;
    for(int i=n;i>=0;i--)
    {
        r=max(a[i+1].dist2,r);
        cost=min(cost,a[i].dist1+r);
    }
    printf("%d\n",cost);
    return 0;
}
